package widgets
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;

	/**
	 * @author Serge
	 * Helper class for arranging the Widget UI.
	 */
	public class Holder extends Sprite
	{
		private var widgetList:Vector.<Sprite>;
		private var bottomY:uint;
		
		public function Holder()
		{
			widgetList = new Vector.<Sprite>();
		}
		
		public function addWidget(widget:DisplayObject, height:uint):void
		{
			widgetList.push(widget);
			addToDisplaylist(widget, height);
		}
		
		private function addToDisplaylist(widget:DisplayObject, height:uint):void
		{
			widget.y = bottomY;
			addChild(widget);
			bottomY += height + 10;
		}
		
		private function getHeight():int
		{
			var max:int = 0;
			for each (var d:DisplayObject in this)
			{
				var bottomY:int = d.y + d.height;
				if (bottomY > max) max = bottomY;
			}
			return max;
		}
	}
}